# _*_ coding: utf-8 _*_
# @Time     : 2022/7/16 18:26
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : tjfx_sj_page.py
# @Software : PyCharm
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
import unittest
from selenium.webdriver.support.select import Select


class SjTongJi(BasePage):
    """商机页面统计"""
    url = "http://192.168.1.5:8081/crm/index.php?m=business&a=analytics"  # 财务统计页面url
    """定位器"""
    teble_dingwei = "table table-hover"
    loudou = "销售漏斗"
    jine = "商机金额统计"
    laiyuan = "商机来源统计"
    qushiri = "趋势分析(按日)"
    qushizhou = "趋势分析(按周)"
    qushiyue = "趋势分析(按月)"
    show_report_locator = (By.ID, "show_report")  # 商机统计报表
    show_status_locator = (By.ID, "show_status")  # 销售漏斗
    show_money_locator = (By.ID, "show_money")  # 商机金额
    show_source_locator = (By.ID, "show_source")  # 来源统计
    show_day_locator = (By.ID, "show_day")  # 趋势分析（日）
    show_week_locator = (By.ID, "show_week")  # 趋势分析（周）
    show_month_locator = (By.ID, "show_month")  # 趋势分析（月）
    table_locator = (By.CSS_SELECTOR, "#report_content > table")
    loudou_locator = (By.CSS_SELECTOR, "#highcharts-24 > svg > text.highcharts-title")
    jine_locator = (By.CSS_SELECTOR, "#highcharts-8 > svg > text.highcharts-title")
    laiyaun_locator = (By.CSS_SELECTOR, "#highcharts-0 > svg > text.highcharts-title")
    qushiri_locator = (By.CSS_SELECTOR, '#highcharts-18 > svg > text.highcharts-title')
    qushiyue_locator = (By.CSS_SELECTOR, '#highcharts-39 > svg > text.highcharts-title')
    qushizhou_locator = (By.CSS_SELECTOR, "#highcharts-33 > svg > text.highcharts-title")

    def status_clic(self):
        """点击商机销售漏斗"""
        self.driver.find_element(*self.show_status_locator).click()

    def money_clic(self):
        """点击商机金额"""
        self.driver.find_element(*self.show_money_locator).click()
    def source_clic(self):
        """点击来源统计"""
        self.driver.find_element(*self.show_source_locator).click()

    def show_day_clic(self):
        """点击按日的趋势分析"""
        self.driver.find_element(*self.show_day_locator).click()

    def show_week_clic(self):
        """点击按周的趋势分析"""
        self.driver.find_element(*self.show_week_locator).click()

    def show_month_clic(self):
        """点击按月的趋势分析"""
        self.driver.find_element(*self.show_month_locator).click()

    def report_clic(self):
        """点击商机报表统计"""
        self.driver.find_element(*self.show_report_locator).click()

    def get_cla(self):
        """获取切换到客户统计报表页面的元素的class"""
        return self.driver.find_element(*self.table_locator).get_attribute("class")

    def get_text1(self):
        """获取切换到漏斗页面的元素文本"""
        return self.driver.find_element(*self.loudou_locator).text

    def get_text2(self):
        """获取切换到金额统计的元素文本"""
        return self.driver.find_element(*self.jine_locator).text

    def get_text3(self):
        """获取切换到来源统计的元素文本"""
        return self.driver.find_element(*self.laiyaun_locator).text

    def get_text4(self):
        """获取切换到按日趋势分析的元素文本"""
        return self.driver.find_element(*self.qushiri_locator).text

    def get_text5(self):
        """获取切换到按周趋势分析的元素文本"""
        return self.driver.find_element(*self.qushizhou_locator).text

    def get_text6(self):
        """获取切换到按月趋势分析的元素文本"""
        return self.driver.find_element(*self.qushiyue_locator).text





if __name__=="__main__":
    unittest.main()